package com.songcha.module_mine.ui.fragment.setting.personal_recommend

import android.os.Bundle
import com.songcha.library_base.base.BaseFragment
import com.songcha.library_business.proxy.personal_recommend.PersonalRecommendManager
import com.songcha.library_common.ui.view.CustomSwitchButton
import com.songcha.library_common.util.ToastUtil
import com.songcha.module_mine.R

class PersonalRecommendFragment:BaseFragment() {
    override fun getLayoutId(): Int {
        return R.layout.mine_fragment_personal_recommend
    }

    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        if(mRootView==null) return
        val csb=mRootView!!.findViewById<CustomSwitchButton>(R.id.mine_csb_personal_recommend)
        csb.setSelect(PersonalRecommendManager.getPersonalRecommendEnabled())
        csb.setOnSelectListener(object :CustomSwitchButton.IOnSelectListener{
            override fun onSelect(isSelect: Boolean, isFromUser: Boolean) {
                if(!isFromUser) return
                PersonalRecommendManager.setPersonalRecommendEnabled(isSelect)
                if(isSelect)
                    ToastUtil.show("已开启个性化推荐")
                else
                    ToastUtil.show("已关闭个性化推荐")
            }
        })

    }
}